Completed
Pull Request — master (#141)
by Maxence
02:47
created

OCA.Circles.App.removeFileList   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
/*
2
 * Copyright (c) 2017 Cooperativa EITA (eita.org.br)
3
 *
4
 * @author Vinicius Cubas Brand <[email protected]>
5
 * @author Daniel Tygel <[email protected]>
6
 *
7
 * This file is licensed under the Affero General Public License version 3
8
 * or later.
9
 *
10
 * See the COPYING-README file.
11
 *
12
 */
13
14
var api = OCA.Circles.api;
0 ignored issues
show
Bug introduced by
The variable OCA seems to be never declared. If this is a global, consider adding a /** global: OCA */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
15
16
(function() {
17
	if (!OCA.Circles) {
0 ignored issues
show
Bug introduced by
The variable OCA seems to be never declared. If this is a global, consider adding a /** global: OCA */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
18
		/**
19
		 * @namespace
20
		 */
21
		OCA.Circles = {};
22
	}
23
24
	OCA.Circles.App = {
25
26
		initFileList: function($el) {
27
			if (this._fileList) {
28
				return this._fileList;
29
			}
30
31
			this._fileList = new OCA.Circles.FileList(
0 ignored issues
show
Bug introduced by
The variable OCA seems to be never declared. If this is a global, consider adding a /** global: OCA */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
32
				$el,
33
				{
34
					id: 'circles',
35
					scrollContainer: $('#app-content'),
36
					fileActions: this._createFileActions(),
37
					config: OCA.Files.App.getFilesConfig()
38
				}
39
			);
40
41
			this._fileList.appName = t('circles', 'Circles');
42
			return this._fileList;
43
		},
44
45
		removeFileList: function() {
46
			if (this._fileList) {
47
				this._fileList.$fileList.empty();
48
			}
49
		},
50
51
		_createFileActions: function() {
52
			// inherit file actions from the files app
53
			var fileActions = new OCA.Files.FileActions();
0 ignored issues
show
Bug introduced by
The variable OCA seems to be never declared. If this is a global, consider adding a /** global: OCA */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
54
			// note: not merging the legacy actions because legacy apps are not
55
			// compatible with the sharing overview and need to be adapted first
56
			fileActions.registerDefaultActions();
57
			fileActions.merge(OCA.Files.fileActions);
58
59
			if (!this._globalActionsInitialized) {
60
				// in case actions are registered later
61
				this._onActionsUpdated = _.bind(this._onActionsUpdated, this);
0 ignored issues
show
Bug introduced by
The variable _ seems to be never declared. If this is a global, consider adding a /** global: _ */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
62
				OCA.Files.fileActions.on('setDefault.app-circles', this._onActionsUpdated);
63
				OCA.Files.fileActions.on('registerAction.app-circles', this._onActionsUpdated);
64
				this._globalActionsInitialized = true;
65
			}
66
67
			// when the user clicks on a folder, redirect to the corresponding
68
			// folder in the files app instead of opening it directly
69
			fileActions.register('dir', 'Open', OC.PERMISSION_READ, '', function (filename, context) {
0 ignored issues
show
Bug introduced by
The variable OC seems to be never declared. If this is a global, consider adding a /** global: OC */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
70
				OCA.Files.App.setActiveView('files', {silent: true});
0 ignored issues
show
Bug introduced by
The variable OCA seems to be never declared. If this is a global, consider adding a /** global: OCA */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
71
				OCA.Files.App.fileList.changeDirectory(OC.joinPaths(context.$file.attr('data-path'), filename), true, true);
0 ignored issues
show
Bug introduced by
The variable OC seems to be never declared. If this is a global, consider adding a /** global: OC */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
72
			});
73
			fileActions.setDefault('dir', 'Open');
74
			return fileActions;
75
		},
76
77
		_onActionsUpdated: function(ev) {
78
			if (!this._fileList) {
79
				return;
80
			}
81
82
			if (ev.action) {
83
				this._fileList.fileActions.registerAction(ev.action);
84
			} else if (ev.defaultAction) {
85
				this._fileList.fileActions.setDefault(
86
					ev.defaultAction.mime,
87
					ev.defaultAction.name
88
				);
89
			}
90
		},
91
92
		/**
93
		 * Destroy the app
94
		 */
95
		destroy: function() {
96
			OCA.Files.fileActions.off('setDefault.app-circles', this._onActionsUpdated);
0 ignored issues
show
Bug introduced by
The variable OCA seems to be never declared. If this is a global, consider adding a /** global: OCA */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
97
			OCA.Files.fileActions.off('registerAction.app-circles', this._onActionsUpdated);
98
			this.removeFileList();
99
			this._fileList = null;
100
			delete this._globalActionsInitialized;
101
		}
102
	};
103
104
})();
105
106
$(document).ready(function() {
107
	$('#app-content-circlesfilter').on('show', function(e) {
108
		OCA.Circles.App.initFileList($(e.target));
0 ignored issues
show
Bug introduced by
The variable OCA seems to be never declared. If this is a global, consider adding a /** global: OCA */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
109
	});
110
	$('#app-content-circlesfilter').on('hide', function() {
111
		OCA.Circles.App.removeFileList();
0 ignored issues
show
Bug introduced by
The variable OCA seems to be never declared. If this is a global, consider adding a /** global: OCA */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
112
	});
113
});
114